import { nextTick } from "vue";
class Utils {
  /* 把el-scroll的滚动条滚动到底部 */
  slideToBottom(innerRef: any, scrollbarRef: any) {
    nextTick(() => {
      const clientHeight = innerRef.value!.clientHeight;
      scrollbarRef.value!.setScrollTop(clientHeight);
    });
  }

  /* 获取token */
  getToken() {
    let token: any = sessionStorage.getItem("token");
    return JSON.parse(token);
  }

  getSession(name: any) {
    let data: any = sessionStorage.getItem(name);
    return JSON.parse(data);
  }

  cloneArray(oldArray: any, newArray: any) {
    oldArray.map((c: any) => newArray.push({ ...c }));
  }
}

export default new Utils();
